package com.leetcode.partition17;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/7 11:39
 */
public class LC1614括号的最大嵌套深度 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String s = reader.readLine();
        writer.write(maxDepth(s) + "\n");
        writer.flush();
    }

    public static int maxDepth(String s) {
        int answer = 0, count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(') count++;
            else if (s.charAt(i) == ')') count--;
            answer = Math.max(answer, count);
        }
        return answer;
    }
}
